package com.yanqu.road.entity.log;

import com.yanqu.road.entity.FieldTypeAnnotation;
import com.yanqu.road.entity.activity.fellingtrees.FellingTreesEquip;

import java.sql.Types;
import java.util.Date;
import java.util.List;
import java.util.Map;

@FieldTypeAnnotation(tableName = "t_l_ck_felling_trees_play", autoSave = true,desc = "吴刚-玩法明细",uploadCk = true)
public class LogFellingTreesPlay extends ServerBaseLog{

    @FieldTypeAnnotation(desc = "活动ID", isIndex = true)
    private int activityId;
    @FieldTypeAnnotation(desc = "玩家ID", isIndex = true)
    private long userId;
    @FieldTypeAnnotation(desc = "法力")
    private String attack;
    @FieldTypeAnnotation(desc = "砍树伤害")
    private String damage;
    @FieldTypeAnnotation(desc = "客户端展示的砍树等级，lastHp大于0时这一级没砍掉")
    private int lastLv;
    @FieldTypeAnnotation(desc = "客户端展示的剩余血量")
    private String lastHp;
    @FieldTypeAnnotation(desc = "金币，包含熔炼")
    private String gold;
    @FieldTypeAnnotation(desc = "熔炼数量")
    private int recycleCount;
    @FieldTypeAnnotation(desc = "掉落法宝，不含已熔炼", sqlType = Types.LONGVARCHAR)
    private String equips;
    @FieldTypeAnnotation(desc = "掉落灵宝")
    private String specItems;
    @FieldTypeAnnotation(desc = "掉落材料")
    private String items;
    @FieldTypeAnnotation(desc = "砍完后的buff")
    private String buff;

    @FieldTypeAnnotation(desc = "消耗体力")
    private int costEnergy;
    @FieldTypeAnnotation(desc = "掉落道器")
    private String daoQi;

    public LogFellingTreesPlay(int activityId, long userId, String attack, String damage, int lastLv, String lastHp, String gold, int recycleCount, List<FellingTreesEquip> equips, String specItems, String items, Map<Integer, Integer> buffMap, int costEnergy, String daoQi) {
        this.activityId = activityId;
        this.userId = userId;
        this.attack = attack;
        this.damage = damage;
        this.lastLv = lastLv;
        this.lastHp = lastHp;
        this.gold = gold;
        this.recycleCount = recycleCount;
        this.equips = parseEquips(equips);
        this.specItems = specItems;
        this.items = items;
        this.buff = parseBuff(buffMap);
        this.costEnergy = costEnergy;
        this.daoQi = daoQi;
    }

    private String parseEquips(List<FellingTreesEquip> equips) {
        StringBuilder sb = new StringBuilder();
        for (FellingTreesEquip equip : equips) {
            sb.append(equip.getUid());
            sb.append("=");
            sb.append(equip.getEquipId());
            sb.append("=");
            sb.append(equip.getBaseLv());
            sb.append("=");
            sb.append(equip.getLv());
            sb.append(";");
        }
        return sb.toString();
    }

    private String parseBuff(Map<Integer, Integer> buffMap) {
        StringBuilder sb = new StringBuilder();
        for (Map.Entry<Integer, Integer> entry : buffMap.entrySet()) {
            sb.append(entry.getKey());
            sb.append("=");
            sb.append(entry.getValue());
            sb.append(";");
        }
        return sb.toString();
    }

    public String getBuff() {
        return buff;
    }

    public void setBuff(String buff) {
        this.buff = buff;
    }

    public int getActivityId() {
        return activityId;
    }

    public void setActivityId(int activityId) {
        this.activityId = activityId;
    }

    public long getUserId() {
        return userId;
    }

    public void setUserId(long userId) {
        this.userId = userId;
    }

    public String getAttack() {
        return attack;
    }

    public void setAttack(String attack) {
        this.attack = attack;
    }

    public String getDamage() {
        return damage;
    }

    public void setDamage(String damage) {
        this.damage = damage;
    }

    public int getLastLv() {
        return lastLv;
    }

    public void setLastLv(int lastLv) {
        this.lastLv = lastLv;
    }

    public String getLastHp() {
        return lastHp;
    }

    public void setLastHp(String lastHp) {
        this.lastHp = lastHp;
    }

    public String getGold() {
        return gold;
    }

    public void setGold(String gold) {
        this.gold = gold;
    }

    public int getRecycleCount() {
        return recycleCount;
    }

    public void setRecycleCount(int recycleCount) {
        this.recycleCount = recycleCount;
    }

    public String getEquips() {
        return equips;
    }

    public void setEquips(String equips) {
        this.equips = equips;
    }

    public String getSpecItems() {
        return specItems;
    }

    public void setSpecItems(String specItems) {
        this.specItems = specItems;
    }

    public String getItems() {
        return items;
    }

    public void setItems(String items) {
        this.items = items;
    }

    public int getCostEnergy() {
        return costEnergy;
    }

    public void setCostEnergy(int costEnergy) {
        this.costEnergy = costEnergy;
    }

    public String getDaoQi() {
        return daoQi;
    }

    public void setDaoQi(String daoQi) {
        this.daoQi = daoQi;
    }

}
